package com.supinfo.food.services;

import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import com.supinfo.food.dao.CustomerDao;
import com.supinfo.food.dao.DaoFactory;
import com.supinfo.food.entities.Customer;
import com.supinfo.food.utils.SerialisationTools;

/**
 * Customer service
 * @author Keitaro
 */
@WebService(name="Customer", serviceName="Customer")
public class CustomerService {

	private CustomerDao dao = DaoFactory.getCustomerDao();
	
	@WebMethod(operationName="addCustomer")
	public String	addCustomer(@WebParam(name="name") String name) {
		Customer customer = new Customer();
		customer.setName(name);
		dao.addCustomer(customer);
		
		return SerialisationTools.serialisation(customer);
	}

//	@WebMethod(operationName="updateCustomer")
//	public Customer	updateCustomer(@WebParam(name="custom") Customer custom) {
//		return dao.updateCustomer(custom);
//	}

//	@WebMethod(operationName="getAllCustomers")
//	public List<Customer> getAllCustomers() {
//		return dao.getAllCustomers();
//	}

//	@WebMethod(operationName="getCustomerById")
//	public Customer getCustomerById(@WebParam(name="id") Long id) {
//		return dao.findCustomer(id);
//	}

	@WebMethod(operationName="removeCustomer")
	public void removeCustomer(@WebParam(name="custom") Customer custom) {
		dao.removeCustomer(custom);
	}
	
	@WebMethod(operationName="remove")
	public void remove(@WebParam(name="custom") Long id) {
		dao.removeCustomer(id);
	}
	
}
